package com.cn.service.imp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cn.common.imp.BaseDao;
import com.cn.common.imp.BaseService;
import com.cn.dao.UserMapper;
import com.cn.model.User;
import com.cn.redis.RedisUtil;
import com.cn.service.IUserService;


@SuppressWarnings("rawtypes")
@Service("userService")
public class UserService extends BaseService<UserMapper> implements IUserService {
	@Autowired
	private BaseDao baseDao = new BaseDao();
	@Autowired
	private RedisUtil redis;
	@SuppressWarnings("unchecked")
	public User getUserById(int userId) {
		this.getName();
		return  (User) this.baseDao.select(userId);
	}
	@Override
	public User getByUsername(String username) {
		/*为搭建redis服务中心，暂时不能使用*/
		/*User us = (User)redis.get(username);
		if(us==null){
		User u = (User)this.baseDao.selectOne(username);
		redis.set(username, u);
		}*/
		this.getName();
		return (User) this.baseDao.selectOne(username);
	}
	public void getName() {
		this.baseDao.setXmlnamespace("UserMapper");
	}

}
